package com.zhongsou.souyue.filemanager;
import android.util.Log;
import java.util.HashMap;

/**
 * Created by Administrator on 2015/5/27.
 */
public class SaveFile {
//    HashMap<SaveType,WriteHandler> hashMap = new HashMap<SaveType, WriteHandler>();
    private WriteDebugHandler debugHandler;
    private WriteCrashHandler crashHandler;
    public SaveFile(String saveFileName,Enum saveFileType){//初始化两个WriteHandler;
        if(saveFileType==SaveType.SAVE_CRASH_FILE_TYPE){
            if(crashHandler==null){
                crashHandler = new WriteCrashHandler(saveFileName);
            }else{
             Log.i("SaveFile","WriteHandler has already exist   saveFileType = 保存Crash");
            }
        }else if(saveFileType == SaveType.SAVE_DEBUG_FILE_TYPE){
            if(debugHandler==null){
                debugHandler = new WriteDebugHandler(saveFileName);
            }else{
                Log.i("SaveFile","WriteHandler has already exist  saveFileType = 保存Debug");
            }
        }
    }

    public void saveDebugLog(String debugInfo){
        if(debugHandler!=null){
            debugHandler.saveLog(debugInfo);
        }else{
            Log.e("SaveFile.saveDebugLog()","saveDebug Handler can't null");
        }
    }

    public void saveCrashLog(String crashInfo){
        if(crashHandler!=null){
            crashHandler.saveLog(crashInfo);
        }else{
            Log.e("SaveFile.saveDebugLog()","saveDebug Handler can't null");
        }
    }

}
